
<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">添加时间</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="时间">
				  <el-time-picker is-range v-model="timeduan" placeholder="选择时间范围" class="select-block"> </el-time-picker>
			</el-form-item>
			<!--<el-form-item label="序  号">
				<el-input v-model="form.vxh" type="text"   placeholder="请输入序号" ></el-input>
			</el-form-item>-->
			<el-form-item label="备  注">
				<el-input v-model="form.vnotes" type="textarea" :rows="2" placeholder="请输入内容" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="生效状态">
				<el-tooltip :content="'Switch value: ' +form.visenable" placement="top">
					<el-switch v-model="form.visenable" on-color="#13ce66" off-color="#ff4949" off-text="禁用" on-text="启用" on-value="Y" off-value="N"></el-switch>
				</el-tooltip>
			</el-form-item>
		</el-form>
		<el-button type="info" class="submit" @click="submit">添加</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
 		props: ['params'],
		data() {
			return {
				form: {
					visenable: 'Y',
					vnotes: '',

					vxh: '',

				},
				vjsid: '',
				timeduan:'',
				dialogTableVisible: true
			}
		},
		created(){
			// alert( this.params);
		},
		methods: {
			submit() {
				// console.log(this.timeduan)
				//检测
				// this.$store.state.loading = true;
			   /* if(!this.mc) {
					this.$message.warning('请填写分类名称');
					this.$store.state.loading = false;
					return;
				} */
				var logininfo = JSON.parse(localStorage.logininfo);
				var time1 = this.$.getLocalTimeNo1(Date.parse(this.timeduan[0]));
				var time2 = this.$.getLocalTimeNo1(Date.parse(this.timeduan[1]));
				var time3 = (time1+"--"+time2)
				var params3 = qs.stringify({
					jsid:this.params,
					sjd: time3,
					notes: this.form.vnotes,
					xh: this.form.vxh,
					isenable: this.form.visenable,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'jssjd/insert', params3)
					.then(res => {
						console.log(res)
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.form{
			/*text-align: center;*/
			margin-top: 20px;
		}
			.select-block {
 		display: block;
 		width: 85%;
 	}
		.input {
			display: inline-block;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
	}
</style>
